home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / misc1 / iv26_w30.zip / SOURCES / WWVIEW.C < prev   
C/C++ Source or Header  |  1992-03-25  |  8KB  |  310 lines

  1. /*
  2.  * Copyright (c) 1987, 1988, 1989 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. /*
  24.  * X11-dependent worldview code
  25.  */
  26.  
  27. #include <InterViews/canvas.h>
  28. #include <InterViews/cursor.h>
  29. #include <InterViews/painter.h>
  30. #include <InterViews/shape.h>
  31. #include <InterViews/world.h>
  32. #include <InterViews/worldview.h>
  33. #include <InterViews/X11/worldrep.h>
  34.  
  35. void WorldView::Init (World* world) {
  36. /*
  37.     WorldRep* rep = world->Rep();
  38.     Window w = RootWindow(rep->display(), rep->screen());
  39.     canvas = new Canvas((void*)w);
  40.     canvas->width = DisplayWidth(rep->display(), rep->screen());
  41.     canvas->height = DisplayHeight(rep->display(), rep->screen());
  42.     canvas->status = CanvasMapped;
  43.     xmax = canvas->width - 1;
  44.     ymax = canvas->height - 1;
  45.     output->SetOverwrite(true);
  46. */
  47. }
  48.  
  49. /*
  50. static const Mask bmask =
  51.     ButtonPressMask|ButtonReleaseMask|OwnerGrabButtonMask|
  52.     PointerMotionMask|PointerMotionHintMask;
  53. */
  54.  
  55. void WorldView::GrabMouse (Cursor* c) {
  56. /*    while (
  57.     XGrabPointer(
  58.         world->Rep()->display(), (Window)canvas->id, True,
  59.         (unsigned int)bmask, GrabModeAsync, GrabModeAsync, None,
  60.         (XCursor)c->Id(), CurrentTime
  61.     ) != GrabSuccess
  62.     ) {
  63.     sleep(1);
  64.     }
  65. */
  66. }
  67.  
  68. void WorldView::UngrabMouse () {
  69. //    XUngrabPointer(world->Rep()->display(), CurrentTime);
  70. }
  71.  
  72. boolean WorldView::GrabButton (unsigned b, unsigned m, Cursor* c) {
  73. /*    XGrabButton(
  74.     world->Rep()->display(), b, m, (Window)canvas->id, True,
  75.     (unsigned int)bmask, GrabModeAsync, GrabModeAsync, None,
  76.     (XCursor)c->Id()
  77.     );
  78.     return true;
  79. */
  80.     return false;
  81. }
  82.  
  83. void WorldView::UngrabButton (unsigned b, unsigned m) {
  84. //    XUngrabButton(world->Rep()->display(), b, m, (Window)canvas->id);
  85. }
  86.  
  87. void WorldView::Lock () {
  88. /*
  89.  * Bad idea to grab the server
  90.  */
  91. }
  92.  
  93. void WorldView::Unlock () {
  94. /*
  95.  * See Lock()
  96.  */
  97. }
  98.  
  99. void WorldView::ClearInput () {
  100. //    XSync(world->Rep()->display(), 1);
  101. }
  102.  
  103. void WorldView::MoveMouse (Coord x, Coord y) {
  104. /*
  105.     XWarpPointer(
  106.     world->Rep()->display(), (Window)canvas->id, (Window)canvas->id,
  107.     0, 0, xmax, ymax, x, ymax - y
  108.     );
  109. */
  110. }
  111.  
  112. void WorldView::Map (RemoteInteractor i) {
  113. //    XMapWindow(world->Rep()->display(), (Window)i);
  114. }
  115.  
  116. void WorldView::MapRaised (RemoteInteractor i) {
  117. //    XMapRaised(world->Rep()->display(), (Window)i);
  118. }
  119.  
  120. void WorldView::Unmap (RemoteInteractor i) {
  121. //    XUnmapWindow(world->Rep()->display(), (Window)i);
  122. }
  123.  
  124. RemoteInteractor WorldView::Find (Coord x, Coord y) {
  125. /*
  126.     Window w;
  127.     Coord rx, ry;
  128.  
  129.     XTranslateCoordinates(
  130.     world->Rep()->display(), (Window)canvas->id, (Window)canvas->id,
  131.     x, ymax - y, &rx, &ry, &w
  132.     );
  133.     return (void*)w;
  134. */
  135.     return nil;
  136. }
  137.  
  138. void WorldView::Move (RemoteInteractor i, Coord left, Coord top) {
  139. //    XMoveWindow(world->Rep()->display(), (Window)i, left, ymax - top);
  140. }
  141.  
  142. void WorldView::Change (
  143.     RemoteInteractor i, Coord left, Coord top, unsigned int w, unsigned int h
  144. ) {
  145. /*
  146.     XMoveResizeWindow(
  147.     world->Rep()->display(), (Window)i, left, ymax - top, w, h
  148.     );
  149. */
  150. }
  151.  
  152. void WorldView::Raise (RemoteInteractor i) {
  153. //    XRaiseWindow(world->Rep()->display(), (Window)i);
  154. }
  155.  
  156. void WorldView::Lower (RemoteInteractor i) {
  157. //    XLowerWindow(world->Rep()->display(), (Window)i);
  158. }
  159.  
  160. void WorldView::Focus (RemoteInteractor i) {
  161. /*
  162.     if (i != curfocus) {
  163.     curfocus = i;
  164.     XSetInputFocus(
  165.         world->Rep()->display(), i == nil ? PointerRoot : (Window)i,
  166.         RevertToPointerRoot, CurrentTime
  167.     );
  168.     }
  169. */
  170. }
  171.  
  172. void WorldView::GetList (RemoteInteractor*& ilist, unsigned int& n) {
  173. /*
  174.     Window parent;
  175.  
  176.     XQueryTree(
  177.     world->Rep()->display(), (Window)canvas->id, &parent, &parent,
  178.     (Window**)&ilist, &n
  179.     );
  180. */
  181. }
  182.  
  183. void WorldView::GetInfo (
  184.     RemoteInteractor i, Coord& x1, Coord& y1, Coord& x2, Coord& y2
  185. ) {
  186. /*
  187.     Window root;
  188.     int x, y;
  189.     unsigned int w, h, bw, d;
  190.  
  191.     XGetGeometry(
  192.     world->Rep()->display(), (Window)i, &root, &x, &y, &w, &h, &bw, &d
  193.     );
  194.     x1 = x;
  195.     y2 = ymax - y;
  196.     x2 = x + w + 2*bw - 1;
  197.     y1 = y2 - h - 2*bw + 1;
  198. */
  199. }
  200.  
  201. boolean WorldView::GetHints (
  202.     RemoteInteractor i, Coord& x, Coord& y, Shape& s
  203. ) {
  204. /*
  205.     XSizeHints sizehints;
  206.  
  207.     sizehints.flags = 0;
  208.     XGetSizeHints(
  209.     world->Rep()->display(), (Window)i, &sizehints, XA_WM_NORMAL_HINTS
  210.     );
  211.     if ((sizehints.flags & USSize) != 0) {
  212.     s.width = sizehints.width;
  213.     s.height = sizehints.height;
  214.     s.hstretch = sizehints.max_width - sizehints.width;
  215.     s.hshrink = sizehints.width - sizehints.min_width;
  216.     s.vstretch = sizehints.max_height - sizehints.height;
  217.     s.vshrink = sizehints.height - sizehints.min_height;
  218.     s.hunits = sizehints.width_inc;
  219.     s.vunits = sizehints.height_inc;
  220.     } else {
  221.     s.width = 0;
  222.     s.height = 0;
  223.     }
  224.     if ((sizehints.flags & USPosition) != 0) {
  225.     x = sizehints.x;
  226.     y = ymax - sizehints.y;
  227.     return true;
  228.     }
  229.     return false;
  230. */
  231.     return false;
  232. }
  233.  
  234. void WorldView::SetHints (RemoteInteractor i, Coord x, Coord y, Shape& s) {
  235. /*
  236.     XSizeHints sizehints;
  237.  
  238.     sizehints.flags = (USPosition | USSize);
  239.     sizehints.x = x;
  240.     sizehints.y = ymax - y;
  241.     sizehints.width = s.width;
  242.     sizehints.height = s.height;
  243.     XSetSizeHints(
  244.     world->Rep()->display(), (Window)i, &sizehints, XA_WM_NORMAL_HINTS
  245.     );
  246. */
  247. }
  248.  
  249. RemoteInteractor WorldView::GetIcon (RemoteInteractor i) {
  250. /*
  251.     XWMHints* h;
  252.     RemoteInteractor r;
  253.  
  254.     h = XGetWMHints(world->Rep()->display(), (Window)i);
  255.     if (h == nil || (h->flags&IconWindowHint) == 0) {
  256.     r = nil;
  257.     } else {
  258.     r = (void*)h->icon_window;
  259.     }
  260.     delete h;
  261.     return r;
  262. */
  263.     return nil;
  264. }
  265.  
  266. /* obsolete - window mgrs should set WM_STATE on clients' toplevel windows */
  267.  
  268. void WorldView::AssignIcon (RemoteInteractor i, RemoteInteractor icon) {
  269. /*
  270.     XWMHints h;
  271.  
  272.     h.flags = IconWindowHint;
  273.     h.icon_window = (Window)i;
  274.     XSetWMHints(world->Rep()->display(), (Window)icon, &h);
  275.     h.icon_window = (Window)icon;
  276.     XSetWMHints(world->Rep()->display(), (Window)i, &h);
  277. */
  278. }
  279.  
  280. void WorldView::UnassignIcon (RemoteInteractor i) {
  281. /*
  282.     XWMHints h;
  283.  
  284.     h.flags = IconWindowHint;
  285.     h.icon_window = None;
  286.     XSetWMHints(world->Rep()->display(), (Window)i, &h);
  287. */
  288. }
  289.  
  290. RemoteInteractor WorldView::TransientOwner (RemoteInteractor i) {
  291. /*
  292.     Window w;
  293.  
  294.     return
  295.     XGetTransientForHint(world->Rep()->display(), (Window)i, &w) ?
  296.         (void*)w : nil;
  297. */
  298.     return nil;
  299. }
  300.  
  301. char* WorldView::GetName (RemoteInteractor i) {
  302. /*
  303.     char* name;
  304.  
  305.     XFetchName(world->Rep()->display(), (Window)i, &name);
  306.     return name;
  307. */
  308.     return nil;
  309. }
  310.